package com.yiquan.search.aop;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author Tyrone
 * @date 2022/3/7 21:30
 */
@Aspect
@Component
@Slf4j
public class LogResponseAop {

    @Pointcut(value = "execution(* com.yiquan.search.controller..*(..))")
    public void pointCut(){

    }

    @Around("pointCut()")
    public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        Object result = proceedingJoinPoint.proceed();
        log.info("返回参数:{}", JSON.toJSONString(result));
        return result;
    }

}
